﻿<include file="Public/head"/>
    <div class="container-fluid">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="myModalLabel">添加回复</h3>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" method="post" enctype="multipart/form-data"
                >
                    <div class="control-group">
                        <label class="control-label">关键字</label>
                        <div class="controls" id="keyword">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">类型</label>
                        <div class="controls">
                            <input type="radio" name='type' value="1" checked/>文本　
                            <input type="radio" name='type' value="2"/>图文　
                            <input type="radio" name="type" value="3"/>事件
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">回复内容</label>
                        <div class="controls">
                            <input type="text" name="content" placeholder="回复内容">
                        </div>
                    </div>
                    <div class="control-group img">
                            <label class="control-label">上传图片</label>
                            <div class="controls">
                                <input type="file" name="file">
                            </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn" onclick='history.go(-1)'>返回</button>
                <button class="btn btn-primary" id="add" onclick="add();">保存</button>
            </div>
    </div>

<include file="Public/foot"/>
<script>
    //拼接select
    var arr = {$keyword};
    var select = '<select name="keyword">';
    for(var i in arr){
        select += '<option value="'+arr[i]+'">'+arr[i]+'</option>';
    }
    select += '</select>';
    //拼接input
    var input = '<input type="text" name="keyword" placeholder="关键字">';
    //根据类型显示和隐藏相应的输入框
    $("input[type='radio']").click(function(){
        var val = $(this).val();
        if(val == 1){
            $('.img').hide();
            $('#keyword').html(input);
            $('.text').show();
        }else if(val == 2){
            $('#keyword').html(input);
            $('.img').show();
        }else{
            $('.img').hide();
            $('#keyword').html(select);
        }
    });
    $("input:checked").click();
</script>
